
#ifndef _BMOTION_H_
#define _BMOTION_H_

#include <BObject>

using namespace BWE;

enum MotionType
{
	Motion_None = (int)0,
	Motion_Linear,
	Motion_OutBounce,
	Motion_InBounce,
	Motion_InOutBounce,
	Motion_OutQuad,
	Motion_InQuad,
	Motion_InOutQuad,
	Motion_OutCubic,
	Motion_InCubic,
	Motion_InOutCubic,
	Motion_InQuart,
	Motion_OutQuart,
	Motion_InOutQuart,
	Motion_OutElastic,
	Motion_InElastic,
	Motion_InOutElastic,
	Motion_OutSine,
	Motion_InSine,
	Motion_InOutSine,
	Motion_OutBack,
	Motion_InBack,
	Motion_InOutBack,
	Motion_OutCirc,
	Motion_InCirc,
	Motion_InOutCirc,
	Motion_OutExpo,
	Motion_InExpo,
	Motion_InOutExpo,
	Motion_Max
};

class Motion : public BObject
{
	BOBJECT(Motion)
public:
	Motion(MotionType type, bool loop = false);
	Motion(double startValue = 0, double duration = 1, bool loop = false);
	~Motion();

	void set(double startValue, double duration, bool loop = false);

	void setLoop(bool loop);
	bool loop() const;

	void setType(MotionType type);
	MotionType type() const;

	void setStartValue(double startValue);
	double startValue() const;

	void setDuration(double duration);
	double duration() const;

	void setUnit(double unit);
	double unit() const;

	bool started() const;

	void reset();
	void start();
	void pause();
	void stop();

	void update(double dt);
	double time() const;
	double value() const;

private:
	MotionType		_type;
	void*			_func;
	bool			_loop;
	bool			_started;
	double			_startTime;
	double			_startValue;
	double			_time;
	double			_value;
	double			_unit;
	double			_duration;

};
typedef BHolder<Motion>	MotionHolder;

#endif